<?php
namespace Web\Model;
use Think\Model;
class ChatModel extends Model{
	/**
	 * 生成房间
	 * 聊天室生成需要数据
	 * aj_id按揭员id goods_id核心信息id
	 * 
	 */
	public function add_chat(){
        if(session('my_kuhu')&&$_SESSION['my_kuhu']['data']){
            $chat['first_user']=$_POST['aj_id'];
            $chat['second_user']=$_SESSION['user']['web_id'];
            $chat['state']=1;
            $chat_id=M('chat')->data($chat)->add();
            if($chat_id){
                $where_chat_id['chat_id']=$chat_id;
                session('chat',M('chat')->where($where_chat_id)->find());
                $lccdc_data['lccdc_id']=session('my_lccdc.lccdc_id');
                $lccdc_data['chat_id']=$chat_id;
                $lccdc=M('lccdc')->save($lccdc_data);
                $my_lccdc=M('lccdc')->where('lccdc_id='.session('my_lccdc.lccdc_id'))->find();
                session('my_lccdc',$my_lccdc);
             /************************from一方建造******************************/
                $from_user_data['from_user_group']=$_POST['aj_id'].','.$_SESSION['user']['web_id'];
                $from_user_data['chat_id']=$_SESSION['chat']['chat_id'];

                $from_user_temp=M('from_user_group')->data($from_user_data)->add();
                $from_data=M('from_user_group')->where('from_user_group_id='.$from_user_temp)->find();
                $_SESSION['chat']['from_user_group']=$from_data;
             /************************from一方建造******************************/
            }
        }
	}

}